﻿//++
//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
// Module Name:
//
//    ConferenceAppointmentTest.cs
//
// Abstract:
//
//    Unit tests for ConferenceAppointment class
//
//--

using System.Diagnostics;
using Microsoft.Office.Interop.Outlook;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Microsoft.EnhancedReminders.OutlookAddIn.UnitTests
{
    /// <summary>
    /// Summary description for ConferenceAppointmentTest
    /// </summary>
    [TestClass]
    public class ConferenceAppointmentTest
    {
        private TestContext testContextInstance;

        // Body of a Live Meeting invitation
        private const string LiveMeetingBody = 
@"-+-----+-----+-----+-----+-----+-----+-----+-----+-

User1 has invited you to attend an online meeting using Microsoft® Office Communications Server.
HYPERLINK ""meet:sip:user1@contoso.com;gruu;opaque=app:conf:focus:id:3c40c68be9e74fcd99e59fd68ff95196%3Fconf-key=PE7Jc2bpW8NR"" Join the meeting.
Audio Information 
Computer Audio
To use computer audio, you need speakers and a microphone, or a headset.
First-Time Users 
Make sure the Office Live Meeting client is installed before the meeting:
I am connecting from HYPERLINK ""http://office.contoso.com/en-us/help/HA101733831033.aspx"" outside the Corporation network
Troubleshooting 
Unable to join the meeting?  Launch the Office Live Meeting client and join the meeting with the following information:
	Meeting ID:	3c40c68be9e74fcd99e59fd68ff95196
	Entry Code:	PE7Jc2bpW8NR
	Location:	meet:sip:user1@contoso.com;gruu;opaque=app:conf:focus:id:3c40c68be9e74fcd99e59fd68ff95196%3Fconf-key=PE7Jc2bpW8NR

If you still cannot enter the meeting, contact support:
HYPERLINK ""https://lslm01.meet.contoso.com/conf/ext/TShoot.html"" Outside the Corporation network
Notice 
Office Live Meeting can be used to record meetings. By participating in this meeting, you agree that your communications may be monitored or recorded at any time during the meeting.";

        // Corresponding Live Meeting Uri. This needs to be updated if the above changed
        private const string LiveMeetingUri = "sip:user1@contoso.com;gruu;opaque=app:conf:focus:id:3c40c68be9e74fcd99e59fd68ff95196?conf-key=PE7Jc2bpW8NR";


        // Body of a Call Conference invitation
        private const string ConferenceCallBody = 
@"-+-----+-----+-----+-----+-----+-----+-----+-----+-


User1 has invited you to a conference call using Microsoft® Office Communicator.
HYPERLINK ""conf:sip:user1@contoso.com;gruu;opaque=app:conf:focus:id:2dbf69a720c64977b3a50855579ea95b%3Fconversation-id=60a98ef59f9845d8b4c3f4229c7322a7"" Join the conference call.
Troubleshooting 
Unable to join the conference call? Copy and paste this link into your Internet browser:
conf:sip:user1@contoso.com;gruu;opaque=app:conf:focus:id:2dbf69a720c64977b3a50855579ea95b%3Fconversation-id=60a98ef59f9845d8b4c3f4229c7322a7";

        // Corresponding Call Conference Uri. This needs to be updated if the above changed.
        private const string CallConferenceUri = "sip:user1@contoso.com;gruu;opaque=app:conf:focus:id:2dbf69a720c64977b3a50855579ea95b";



        private const string NonConferenceBody =
@"When: Monday, July 23, 2007 12:00 PM-1:00 PM (GMT-08:00) Pacific Time (US & Canada).
Where: Conf Room xxx (12) AV

*~*~*~*~*~*~*~*~*~*

Let’s get together to review the Financial statement for FY 2007.

I’ll send out a link later this week for the statement.

Thanks,
User2";

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        //
        // You can use the following additional attributes as you write your tests:
        //
        // Use ClassInitialize to run code before running the first test in the class
        // [ClassInitialize()]
        // public static void MyClassInitialize(TestContext testContext) { }
        //
        // Use ClassCleanup to run code after all tests in a class have run
        // [ClassCleanup()]
        // public static void MyClassCleanup() { }
        //
        // Use TestInitialize to run code before running each test 
        // [TestInitialize()]
        // public void MyTestInitialize() { }
        //
        // Use TestCleanup to run code after each test has run
        // [TestCleanup()]
        // public void MyTestCleanup() { }
        //
        #endregion

        /// <summary>
        /// Verify that the correct Live Meeting information is extracted
        /// </summary>
        [TestMethod]
        public void LiveMeetingInvitationTest()
        {
            ConferenceInfo conferenceInfo = new ConferenceInfo(LiveMeetingBody);

            Assert.AreEqual<string>(LiveMeetingUri, conferenceInfo.ConferenceAddress, "Live Meeting Uri is not as expected");
            Assert.AreEqual(ConferenceType.LiveMeeting, conferenceInfo.ConferenceType, "ConferenceType incorrect");
        }

        /// <summary>
        /// Verify that correct Conference Call information is extracted
        /// </summary>
        [TestMethod]
        public void ConferenceCallInvitationTest()
        {
            ConferenceInfo conferenceInfo = new ConferenceInfo(ConferenceCallBody);

            Assert.AreEqual(ConferenceType.ConferenceCall, conferenceInfo.ConferenceType, "ConferenceType incorrect");
        }
        
        /// <summary>
        /// Verify that correct information is returned when parsing a non conference appointment
        /// </summary>
        [TestMethod]
        public void NonConferenceTest()
        {
            ConferenceInfo conferenceInfo = new ConferenceInfo(NonConferenceBody);

            Assert.IsNull(conferenceInfo.ConferenceAddress, "Meeting Uri should be null for non conference invitation");
        }
    }
}
